package com.ptit.giaothong.tracnghiem;

import java.util.List;

import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.ptit.giaothong.GlobalData;
import com.ptit.giaothong.ItemScores;
import com.ptit.giaothong.MainActivity;
import com.ptit.giaothong.R;

public class Result {
	private Activity activity;
	private TextView countpointtxt, captxt, desc;
	private Button tryplay, savePoint;

	public Result(Activity activity) {
		this.activity = activity;

	}

	public void Init(int countpoint, int total) {

		activity.setContentView(R.layout.endgame);
		Button btn_try = (Button) activity.findViewById(R.id.btn_try);
		btn_try.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				PlayGame playGame = new PlayGame(activity);
				playGame.init(1);
			}
		});

		String trinhdo;
		String desctxt;
		String ghichu1 = activity.getResources()
				.getString(R.string.lb_chucmung);
		String ghichu2 = activity.getResources().getString(R.string.lb_xit);

		countpointtxt = (TextView) activity.findViewById(R.id.totalpoint_id);
		countpointtxt.setText(total + "/" + " 15 câu" + ", Với số điểm "
				+ countpoint + " điểm");

		if (total < 5) {
			trinhdo = "Có thế thôi ah.";
			desctxt = ghichu2;
		} else if (total > 5 && total < 10) {
			trinhdo = "Có cố gắng";
			desctxt = ghichu2;
		} else if (total > 10 && total < 13) {
			trinhdo = "Củng kinh đấy.";
			desctxt = ghichu1;
		} else {
			desctxt = ghichu1;
			trinhdo = "Quá kinh.";
		}

		captxt = (TextView) activity.findViewById(R.id.cap_id);
		captxt.setText(trinhdo);

		desc = (TextView) activity.findViewById(R.id.txtghichu);
		desc.setText(desctxt);

		tryplay = (Button) activity.findViewById(R.id.btn_try);
		savePoint = (Button) activity.findViewById(R.id.btn_luudiem);
		
		
		

		tryplay.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				activity.finish();
				PlayGame playGame = new PlayGame(activity);
				playGame.init(1);
			}
		});
	}
}
